/*
 * @Description: [ 设置信息 ]
 * @Author: Iseven Monkey <iswoter@gmail.com>
 * @Date: 2023-09-08 10:37:34
 * @LastEditors: Iseven Monkey <iswoter@gmail.com>
 * @LastEditTime: 2023-11-18 21:04:21
 */

// 状态
const state = {
  // 设置信息
  settings: { model: {} },
};

const mutations = {
  setSettings(state, settings) {
    // console.log('state.settings;', state.settings);
    state.settings = {
      ...state.settings,
      ...settings,
    };
  },
};

const actions = {
  setSettings({ commit, state }, settings) {
    commit("setSettings", settings);
  },

  getSettings({ commit }) {
    return new Promise((resolve, reject) => {
      apiGetSettings()
        .then((res) => {
          commit("setSettings", res.data);
          resolve(res);
        })
        .catch((err) => {
          resolve(err);
        });
    });
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
